import json
from apps.merchant.item.dao import ItemDao
from apps.user.dao import UserDao
from apps.pay.recordIncomes.dao import RecordIncomesDao

def incomesDeductionActivityHandle(order):
    _order = order
    if _order.realPayIncomes > 0:
        # 扣除积分
        _payScene = 'incomes'
        _realPay = _order.realPayIncomes
        UserDao().subWallet(_payScene, _order.user, _realPay)
        data = {}
        data['scene'] = 'expense'
        data['user'] = _order.user.id
        data['fromUser'] = _order.user.id
        data['orderId'] = _order.orderId
        data['money'] = _realPay
        data['payway'] = _payScene
        data['changeWay'] = 'sub'
        data['orderStatus'] = 'FINISH'
        RecordIncomesDao().create(data)
